<%@ page language="java" 
	contentType="text/html; 
	charset=UTF-8"
	pageEncoding="UTF-8"
	import="connectMysql.TestConnect"
	%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>检查</title>
</head>
<body>
<%
	String message = "";
	String redirectPage = "";
	String userid=request.getParameter("username");
	String psw=request.getParameter("password");
	String type=request.getParameter("type");
	boolean res_name=connectMysql.TestConnect.check_user_exist(userid,type);
	boolean res_psw=connectMysql.TestConnect.check_psw_right(psw,userid);
	if (res_name&&res_psw) {//用户名和密码都返回true
        response.sendRedirect("main.jsp?id="+userid);//这里要传递用户名称！！！！！
    } 
	else {//判断出错的类型给出报错
        if (userid=="") {
            message = "用户名输入不得为空！";
        }else if(psw==""){
        	message = "密码输入不得为空！";
        }else if(!res_name){
        	message = "该账号不存在！";//可能就是没有这个用户，也有可能用户类型错误
        }else if(!res_psw){
        	message = "密码错误！";
        }
    redirectPage = "login.jsp";
%>
<script>
    alert("<%= message %>");
    window.location.href = "<%= redirectPage %>";
</script>
<%
    }
%>

</body>
</html>